package client_gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.FlowLayout;

import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import net.miginfocom.swing.MigLayout;

import javax.swing.JLabel;

import client_controllers.EmployeeLoginController;
import client_controllers.MarketingEmployeeController;
import client_controllers.ProductController;

import javax.swing.JComboBox;
import javax.swing.JTextField;

public class ProductGUI extends JFrame {
	/**
	 * @class ProductGUI generates frame for product lists & catalog
	 */

	private JPanel contentPane;
	private JLabel lblMsg;
	private JButton btnAddProduct;
	private JButton btnRemoveProduct;
	private JComboBox comboBox;
	private JTextField name;
	private JTextField price;
	private JLabel lblProductName;
	private JLabel lblProductPrice;
	private JTextField description;
	private JLabel lblProductDescription;
	private JLabel lblUploadPhoto;
	private JTextField photo;
	private JButton btnBack;

	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ProductGUI1 frame = new ProductGUI1();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}*/

	

	/**
	 * Create the frame.
	 */
	public ProductGUI(MarketingEmployeeController mec,EmployeeLoginController elc) {
		setTitle("Product GUI");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new MigLayout("", "[][grow][][][][][grow]", "[][][][][][][][]"));
		
		lblMsg = new JLabel("msg");
		contentPane.add(lblMsg, "cell 1 0");
		
		btnBack = new JButton("Back");
		contentPane.add(btnBack, "cell 6 0");
		
		lblProductName = new JLabel("Product name : ");
		contentPane.add(lblProductName, "cell 0 1,alignx trailing");
		
		name = new JTextField();
		contentPane.add(name, "cell 1 1,growx");
		name.setColumns(10);
		
		lblProductPrice = new JLabel("Product price :");
		contentPane.add(lblProductPrice, "cell 0 2,alignx trailing");
		
		price = new JTextField();
		contentPane.add(price, "cell 1 2,growx");
		price.setColumns(10);
		
		lblProductDescription = new JLabel("Product description:");
		contentPane.add(lblProductDescription, "cell 0 3,alignx trailing");
		
		description = new JTextField();
		contentPane.add(description, "cell 1 3,growx");
		description.setColumns(10);
		
		lblUploadPhoto = new JLabel("Upload photo : ");
		contentPane.add(lblUploadPhoto, "cell 0 4,alignx trailing");
		
		photo = new JTextField();
		contentPane.add(photo, "cell 1 4,growx");
		photo.setColumns(10);
		
		comboBox = new JComboBox();
		contentPane.add(comboBox, "cell 6 6,growx");
		
		btnAddProduct = new JButton("Add product");
		contentPane.add(btnAddProduct, "cell 1 7");
		
		btnRemoveProduct = new JButton("Remove product");
		contentPane.add(btnRemoveProduct, "cell 6 7");
		this.lblMsg.setVisible(false);
		this.setVisible(true);
		ProductController pc = new ProductController(this,elc,mec);
	}
	public void AddItemLis(ActionListener lis){
		this.getBtnAddProduct().addActionListener(lis);
	}
	public void RemoveItemListener(ActionListener lis){
		this.getBtnRemoveProduct().addActionListener(lis);
	}
	public JLabel getLblMsg() {
		return lblMsg;
	}

	public void setLblMsg(String string) {
		this.lblMsg.setText(string);
	}

	public JButton getBtnAddProduct() {
		return btnAddProduct;
	}

	public void setBtnAddProduct(JButton btnAddProduct) {
		this.btnAddProduct = btnAddProduct;
	}

	public JButton getBtnRemoveProduct() {
		return btnRemoveProduct;
	}

	public void setBtnRemoveProduct(JButton btnRemoveProduct) {
		this.btnRemoveProduct = btnRemoveProduct;
	}
	public JComboBox getComboBox() {
		return comboBox;
	}
	public void setComboBox(JComboBox comboBox) {
		this.comboBox = comboBox;
	}
	public String getName() {
		return name.getText();
	}
	public void setName(JTextField name) {
		this.name = name;
	}
	public float getPrice() {
		return Float.parseFloat(price.getText());
	}
	public void setPrice(JTextField price) {
		this.price = price;
	}
	public String getDescription() {
		return description.getText();
	}
	public void setDescription(JTextField description) {
		this.description = description;
	}
	public JTextField getPhoto() {
		return photo;
	}
	public void setPhoto(JTextField photo) {
		this.photo = photo;
	}
	public JButton getBtnBack() {
		return btnBack;
	}
	public void setBtnBack(JButton btnBack) {
		this.btnBack = btnBack;
	}
	

}
